from aliyun.log.etl_core import *

DROP_FIELDS_v1 = True
DROP_FIELDS_v2 = False
DROP_FIELDS_v3 = [True]
DROP_FIELDS_v4 = [False]
DROP_FIELDS_v5 = {'k1': r'\d+'}
DROP_FIELDS_v6 = [{'k1': r'\d+'}]
DROP_FIELDS_v9 = [{'k1': r'\d+'}, {'k2': r'\d+'}]
DROP_FIELDS_v10 = [{'k1': r'\d+', 'k2': r'\w+'}]
DROP_FIELDS_v7 = {'k4': None}
DROP_FIELDS_v11 = {'k1': True}
DROP_FIELDS_v12 = {'k1': False}

TRANSFORM_EVENT_v1 = (ANY, {'k3': 'abc123'})
TRANSFORM_EVENT_v2 = (ANY, ("k1", r"hello (?P<name>\w+)"))
TRANSFORM_EVENT_v3 = (ANY, ("k1", r"(?i)(?P<word>[a-z]+)(?P<num>\d+)"))
TRANSFORM_EVENT_v4 = (ANY, ("k1", r"(?P<abc>\d+)"))
TRANSFORM_EVENT_v5 = (ANY, ("k1", r".*?(?P<abc>\d+)") )
TRANSFORM_EVENT_v7 = (ANY, (["k1", 'k2'], r"(?P<abc>\d+)"))
TRANSFORM_EVENT_v9 = (ANY, ("k1", REGEX(r"^(?P<abc>\d+)$") ))
TRANSFORM_EVENT_v10 = (ANY, ("k1", REGEX(r"(?P<abc>\d+)") ))
TRANSFORM_EVENT_v11 = (ANY, ("k1", REGEX(r"\d+", "f1")) )
TRANSFORM_EVENT_v12 = (ANY, ("k1", r"\d+", ["f1", "f2"]))
TRANSFORM_EVENT_v13 = (ANY, ("k1", r"(\w+) (\d+)", ["f1", "f2"]) )
TRANSFORM_EVENT_v14 = (ANY, ("k1", REGEX(r"(?P<abc>\d+)") ))
TRANSFORM_EVENT_v15 = (ANY, ("k1", r"(\d+) (\d+)", ["f1", "f2"]))
TRANSFORM_EVENT_v16 = (ANY, ("k1", r"(\w+):(\d+)", {r"k_\1": r"v_\2"}))


TRANSFORM_EVENT_v17 = (ANY,  ("data", CSV(r"city,pop,province")) )
TRANSFORM_EVENT_v18 = (ANY,  ("data", CSV(['city', 'pop', 'province'])) )
TRANSFORM_EVENT_v19 = (ANY,  ("data", CSV(r"city, pop, province", sep='#')) )
TRANSFORM_EVENT_v20 = (ANY,  ("data", CSV(r"city, pop, province", lstrip=False)) )
TRANSFORM_EVENT_v21 = (ANY,  ("data", CSV(r"city, pop, province", quote='|')) )
TRANSFORM_EVENT_v22 = (ANY,  ("data", CSV(r"city, pop, province", restrict=True)) )
TRANSFORM_EVENT_v23 = (ANY,  ("data", TSV(r"city,pop,province")) )
TRANSFORM_EVENT_v24 = (ANY,  ("data", PSV(r"city,pop,province")) )

TRANSFORM_EVENT_v25 = (ANY,  ("pro", LOOKUP({"1": "TCP", "2": "UDP", "3": "HTTP", "*": "Unknown"}, "protocol")) )
TRANSFORM_EVENT_v26 = (ANY,  ("pro", LOOKUP({"1": "TCP", "2": "UDP", "3": "HTTP"}, "protocol")) )
TRANSFORM_EVENT_v27 = (ANY,  ("pro", LOOKUP({"http": "tcp", "dns": "udp", "https": "tcp"}, "type")) )
TRANSFORM_EVENT_v28 = (ANY,  ("pro", LOOKUP({"http": "tcp", "dns": "udp", "https": "tcp", "*": "Unknown"}, "type", case_insensitive=False)) )
TRANSFORM_EVENT_v29 = (ANY,  (["pro", "protocol"], LOOKUP({"http": "tcp", "dns": "udp", "https": "tcp"}, "type")) )

TRANSFORM_EVENT_v30 = (ANY,  ("city", LOOKUP('abc.csv', "province")) )
TRANSFORM_EVENT_v31 = (ANY,  ("city", LOOKUP('abc.csv', ["province", "pop"])) )
TRANSFORM_EVENT_v32 = (ANY,  ("city", LOOKUP('abc.csv', ["province", "pop"], lstrip=False)) )
TRANSFORM_EVENT_v35 = (ANY,  ("city", LOOKUP('abc.csv', ["city,province", "city,pop"])) )
TRANSFORM_EVENT_v37 = (ANY,  ("city", LOOKUP('abc.csv', ["province", "pop"], quote='|')) )
TRANSFORM_EVENT_v39 = (ANY,  ("ct", LOOKUP('abc.csv', "pro", headers=["ct", "pop", "pro"])) )
TRANSFORM_EVENT_v40 = (ANY,  ("ct2", LOOKUP('abc.csv', "pro", headers="ct2, pop , pro")) )

TRANSFORM_EVENT_v51 = (ANY,   ("city", LOOKUP("abc.csv", "province") )  )
TRANSFORM_EVENT_v52 = (ANY,   (["city", "province"], LOOKUP("abc.csv", "pop") )  )
TRANSFORM_EVENT_v53 = (ANY,   ("city", LOOKUP("abc.csv", "province") )  )
TRANSFORM_EVENT_v54 = (ANY,   ("pro", LOOKUP("abc.csv", "type") )  )
TRANSFORM_EVENT_v56 = (ANY,  ("pro", LOOKUP("abc.csv", "type", case_insensitive=False)) )
TRANSFORM_EVENT_v58 = (ANY,   (["city", "province"], LOOKUP("abc.csv", "pop") )  )
TRANSFORM_EVENT_v59 = (ANY,   (["city", "province"], LOOKUP("abc.csv", ["pop", "type"]) )  )
TRANSFORM_EVENT_v60 = (ANY,   ([("ct", "city"), "province"], LOOKUP("abc.csv", "pop") )  )
TRANSFORM_EVENT_v61 = (ANY,   ([("ct", "city"), ("prv", "province")], LOOKUP("abc.csv", "pop") )  )
TRANSFORM_EVENT_v62 = (ANY,   (["city", "province"], LOOKUP("abc.csv", [("pop", "population"), ("type", "city_type") ]) )  )
TRANSFORM_EVENT_v63 = (ANY,   ([("ct", "city"), ("prv", "province")], LOOKUP("abc.csv", [("pop", "population")] ) ) )
TRANSFORM_EVENT_v64 = (ANY,   (["c1", "c2"], LOOKUP("abc.csv", ["d1", "d2"]) )  )
TRANSFORM_EVENT_v67 = (ANY,   ("data", KV)  )
TRANSFORM_EVENT_v80 = (ANY,  ("data", KV(sep='(?::|=)')) )
TRANSFORM_EVENT_v81 = (ANY,  ("data", KV(quote="'")) )
TRANSFORM_EVENT_v82 = (ANY,   ("data", KV(prefix="d_", suffix="_e"))  )
TRANSFORM_EVENT_v83 = (ANY,   (["data1", "data2"], KV)  )
KV_FIELDS_x1 = (ANY,   (["data1", "data2"]) )
KV_FIELDS_x2 = (ANY,   (r'data2') )
TRANSFORM_EVENT_v84 = (ANY,   ("data", KV)  )
TRANSFORM_EVENT_v85 = (ANY,   ("data", SPLIT)  )
TRANSFORM_EVENT_v88 = (ANY,  ("data", SPLIT(sep=' )') ) )
TRANSFORM_EVENT_v90 = (ANY,   ("data", SPLIT(lstrip=False) ) )
TRANSFORM_EVENT_v94 = (ANY,   ("data", SPLIT(quote='|') ) )
TRANSFORM_EVENT_v95 = (ANY,   ("data", SPLIT(output="v"))  )
TRANSFORM_EVENT_v96 = (ANY,   ("data", SPLIT(jmes="jmes filter", output='data'))  )
TRANSFORM_EVENT_v97 = (ANY,   ("data", SPLIT(jmes="jmes filter", sep='.', output='data'))  )
TRANSFORM_EVENT_v110 = (ANY,   ("data", JSON(jmes="jmes filter", output='data'))  )
TRANSFORM_EVENT_v113 = (ANY,  ("data", JSON(jmes="jmes filter", output='data', jmes_ignore_none=False)) )
TRANSFORM_EVENT_v114 = (ANY,   ("data", JSON(jmes="jmes filter", output='data'))  )
TRANSFORM_EVENT_v116 = (ANY,   ("data", JSON(jmes='k2', output='k3'))  )
TRANSFORM_EVENT_v117 = (ANY,   ("data", JSON)  )
TRANSFORM_EVENT_v119 = (ANY,   ("data", JSON(depth=1))  )
TRANSFORM_EVENT_v121 = (ANY,   ("data", JSON(prefix="data_", suffix="_end"))  )
TRANSFORM_EVENT_v122 = (ANY,  ("data", JSON(fmt='full')) )
TRANSFORM_EVENT_v123 = (ANY,  ("data", JSON(fmt='parent')) )
TRANSFORM_EVENT_v124 = (ANY,  ("data", JSON(fmt='root')) )
TRANSFORM_EVENT_v125 = (ANY,  ("data", JSON(fmt='full', sep="_")) )
TRANSFORM_EVENT_v126 = (ANY,  ("data", JSON(fmt='parent', sep="_")) )
TRANSFORM_EVENT_v127 = (ANY,  ("data", JSON(fmt='full', sep=" )")) )
TRANSFORM_EVENT_v128 = (ANY,  ("data", JSON(fmt='parent', sep="@", prefix="__", suffix="__")) )
TRANSFORM_EVENT_v129 = (ANY,  ("data", JSON(fmt='{parent_rlist[1]}-{parent_rlist[0]}')) )
TRANSFORM_EVENT_v132 = (ANY,   ("data", JSON(expand_array=False))  )
TRANSFORM_EVENT_v134 = (ANY,  ("people", JSON(fmt='parent')) )
TRANSFORM_EVENT_v135 = (ANY,  ("people", JSON(fmt='parent', fmt_array="{parent_rlist[0]}-{index}")) )
TRANSFORM_EVENT_v136 = (ANY,  ("data", JSON(include_node='k5')) )
TRANSFORM_EVENT_v139 = (ANY,  ("data", JSON(exclude_node=r'k55')) )
TRANSFORM_EVENT_v142 = (ANY,  ("data", JSON(include_path='data.k1')) )
TRANSFORM_EVENT_v145 = (ANY,  ("data", JSON(exclude_path='data.k1')) )
TRANSFORM_EVENT_v148 = (ANY,   ("data", JSON(jmes="jmes filter", output='data', expand=True))  )
TRANSFORM_EVENT_v149 = (ANY,   ("data", JSON(jmes="jmes filter", output='data'))  )
TRANSFORM_EVENT_v150 = (ANY,   [("data", JSON(jmes="jmes filter", output='data', expand=True, exclude_path=r'.+version')), DROP_F('data')]  )
TRANSFORM_EVENT_v151 = (ANY,   [("data", JSON(jmes="jmes filter", fmt='full')), DROP_F('data')]  )
TRANSFORM_EVENT_v152 = (ANY,   {"combine": ZIP("f1", "f2")} )
TRANSFORM_EVENT_v155 = (ANY,   {"combine": ZIP("f1", "f2", sep="|")} )
TRANSFORM_EVENT_v156 = (ANY,   {"combine": ZIP("f1", "f2", quote='|')} )
TRANSFORM_EVENT_v157 = (ANY,   {"combine": ZIP("f1", "f2", combine_sep="|")} )
TRANSFORM_EVENT_v160 = (ANY,  {"combine": ZIP("f1", "f2", lparse=(",", '|'), rparse=(",", '"'))} )

